package com.tgy;

import org.yaml.snakeyaml.Yaml;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;

/***
 * @ClassName: readYml
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 14:44 2021/12/13
 * @version : V1.0
 */
public class readYml {
    public static void main(String[] args) throws IOException {
        InputStream in = readYml.class.getClassLoader().getResourceAsStream("mail.properties");
        Properties properties = new Properties();
        properties.load(in);
        properties.setProperty("aaaa","6666");
        Map properties1 = (Map) properties;
        System.out.println(properties1);
        String property = properties.getProperty("host");
        System.out.println(properties);
        System.out.println(property);


        Yaml yaml = new Yaml();
        InputStream input = readYml.class.getClassLoader().getResourceAsStream("mailConfig.yaml");
        Map<String, Object> map = yaml.loadAs(input, Map.class);
        System.out.println(map);
        System.out.println(map.getOrDefault("bb", "6").toString());
        String a = ((Map<String, Object>) map.get("mail")).get("host").toString();
        String b = ((Map<String, Object>) map.get("aaa")).get("host").toString();
        System.out.println(a);
        System.out.println(b);

    }
}
